// 全局变量

#include "head.h"
#include "define.h"
#include "func.h"
#include "data.h"

int** recoveryMAP = NULL; // 用于复原
int** restartMAP = NULL;  // 用于重启
int** map = NULL;         // 用于变化

int x;
int y; // 人物所在的坐标

int tx, ty;
int ttx, tty;   // 次坐标

int boxes = 0;  // 盒子数

char direction; // 用于接受键盘输入的字符

int level = 1;     // 当前关卡
int maxLevel = 15; // 最大关卡数（决定在何时循环关卡）

int width;
int height;  // 画面的宽高


// 各种图片文件
IMAGE BkImg;  // 背景图片
IMAGE Blank;  // 空白
IMAGE Wall;   // 墙
IMAGE Human;  // 人（是在下的头像，你也可以更换为其他自己喜欢的图片，要求64*64像素）
IMAGE Box;    // 盒子
IMAGE Dest;   // 目的地
IMAGE Box_D;  // 完成的箱子
IMAGE Miku;   // Miku
IMAGE Explain;// 右上角的提示


// 以下是存储地图数据的二维数组

/**
 * 0 表示空
 * 1 表示墙
 * 2 表示人
 * 3 表示箱子
 * 4 表示目的地
 * 5 表示已完成的箱子
 */

 /* Map Start */
const int map_1[8][8] = {
		{0, 0, 1, 1, 1, 0, 0, 0},
		{0, 0, 1, 4, 1, 0, 0, 0},
		{0, 0, 1, 0, 1, 1, 1, 1},
		{1, 1, 1, 3, 0, 3, 4, 1},
		{1, 4, 0, 3, 2, 1, 1, 1},
		{1, 1, 1, 1, 3, 1, 0, 0},
		{0, 0, 0, 1, 4, 1, 0, 0},
		{0, 0, 0, 1, 1, 1, 0, 0}
};

const int recMap_1[8][8] = {
		{0, 0, 1, 1, 1, 0, 0, 0},
		{0, 0, 1, 4, 1, 0, 0, 0},
		{0, 0, 1, 0, 1, 1, 1, 1},
		{1, 1, 1, 0, 0, 0, 4, 1},
		{1, 4, 0, 0, 0, 1, 1, 1},
		{1, 1, 1, 1, 0, 1, 0, 0},
		{0, 0, 0, 1, 4, 1, 0, 0},
		{0, 0, 0, 1, 1, 1, 0, 0}
};

const int map_2[8][8] = {
		{1, 1, 1, 1, 1, 1, 1, 1},
		{1, 0, 0, 0, 1, 0, 0, 1},
		{1, 0, 1, 0, 0, 3, 4, 1},
		{1, 0, 0, 0, 0, 3, 4, 1},
		{1, 0, 1, 0, 0, 3, 4, 1},
		{1, 0, 0, 0, 0, 0, 0, 1},
		{1, 1, 1, 1, 0, 2, 0, 1},
		{0, 0, 0, 0, 1, 1, 1, 1}
};

const int recMap_2[8][8] = {
		{1, 1, 1, 1, 1, 1, 1, 1},
		{1, 0, 0, 0, 1, 0, 0, 1},
		{1, 0, 1, 0, 0, 0, 4, 1},
		{1, 0, 0, 0, 0, 0, 4, 1},
		{1, 0, 1, 0, 0, 0, 4, 1},
		{1, 0, 0, 0, 0, 0, 0, 1},
		{1, 1, 1, 1, 0, 0, 0, 1},
		{0, 0, 0, 0, 1, 1, 1, 1}
};

const int map_3[9][10] = {
		{0, 0, 1, 1, 1, 1, 0, 0, 0, 0},
		{0, 0, 1, 0, 0, 1, 1, 1, 1, 1},
		{1, 1, 1, 0, 4, 0, 0, 0, 0, 1},
		{1, 2, 0, 0, 3, 0, 0, 0, 0, 1},
		{1, 0, 1, 0, 5, 1, 1, 1, 1, 1},
		{1, 0, 0, 0, 3, 0, 0, 1, 0, 0},
		{1, 1, 1, 0, 4, 0, 0, 1, 0, 0},
		{0, 0, 1, 0, 0, 1, 1, 1, 0, 0},
		{0, 0, 1, 1, 1, 1, 0, 0, 0, 0}
};

const int recMap_3[9][10] = {
		{0, 0, 1, 1, 1, 1, 0, 0, 0, 0},
		{0, 0, 1, 0, 0, 1, 1, 1, 1, 1},
		{1, 1, 1, 0, 4, 0, 0, 0, 0, 1},
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
		{1, 0, 1, 0, 4, 1, 1, 1, 1, 1},
		{1, 0, 0, 0, 0, 0, 0, 1, 0, 0},
		{1, 1, 1, 0, 4, 0, 0, 1, 0, 0},
		{0, 0, 1, 0, 0, 1, 1, 1, 0, 0},
		{0, 0, 1, 1, 1, 1, 0, 0, 0, 0}
};

const int map_4[10][11] = {
		{0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0},
		{1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0},
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
		{1, 4, 3, 5, 5, 5, 5, 5, 0, 1, 0},
		{1, 0, 0, 0, 2, 1, 0, 5, 0, 1, 0},
		{1, 1, 1, 1, 1, 1, 0, 5, 0, 1, 1},
		{0, 0, 0, 0, 0, 1, 0, 5, 0, 0, 1},
		{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
		{0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
		{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}
};

const int recMap_4[10][11] = {
		{0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0},
		{1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0},
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
		{1, 4, 0, 4, 4, 4, 4, 4, 0, 1, 0},
		{1, 0, 0, 0, 0, 1, 0, 4, 0, 1, 0},
		{1, 1, 1, 1, 1, 1, 0, 4, 0, 1, 1},
		{0, 0, 0, 0, 0, 1, 0, 4, 0, 0, 1},
		{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
		{0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
		{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}
};

const int map_5[9][7] = {
		{0, 1, 1, 1, 1, 1, 0},
		{0, 1, 0, 2, 0, 1, 0},
		{0, 1, 3, 4, 3, 1, 0},
		{1, 1, 0, 5, 0, 1, 0},
		{1, 0, 0, 5, 0, 1, 1},
		{1, 0, 0, 5, 0, 0, 1},
		{1, 0, 0, 5, 0, 0, 1},
		{1, 1, 1, 0, 0, 1, 1},
		{0, 0, 1, 1, 1, 1, 0}
};

const int recMap_5[9][7] = {
		{0, 1, 1, 1, 1, 1, 0},
		{0, 1, 0, 4, 0, 1, 0},
		{0, 1, 0, 4, 0, 1, 0},
		{1, 1, 0, 4, 0, 1, 0},
		{1, 0, 0, 4, 0, 1, 1},
		{1, 0, 0, 4, 0, 0, 1},
		{1, 0, 0, 4, 0, 0, 1},
		{1, 1, 1, 0, 0, 1, 1},
		{0, 0, 1, 1, 1, 1, 0}
};

const int map_6[8][8] = {
		{1, 1, 1, 1, 1, 1, 1, 0},
		{1, 0, 0, 0, 0, 0, 1, 0},
		{1, 4, 5, 5, 5, 5, 1, 1},
		{1, 0, 0, 0, 0, 0, 0, 1},
		{1, 1, 1, 1, 0, 0, 0, 1},
		{0, 0, 0, 1, 3, 3, 4, 1},
		{0, 0, 0, 1, 2, 0, 1, 1},
		{0, 0, 0, 1, 1, 1, 1, 0}
};

const int recMap_6[8][8] = {
		{1, 1, 1, 1, 1, 1, 1, 0},
		{1, 0, 0, 0, 0, 0, 1, 0},
		{1, 4, 4, 4, 4, 4, 1, 1},
		{1, 0, 0, 0, 0, 0, 0, 1},
		{1, 1, 1, 1, 0, 0, 0, 1},
		{0, 0, 0, 1, 0, 0, 4, 1},
		{0, 0, 0, 1, 0, 0, 1, 1},
		{0, 0, 0, 1, 1, 1, 1, 0}
};

const int map_7[7][8] = {
		{1, 1, 1, 1, 1, 1, 1, 1},
		{1, 4, 5, 4, 5, 4, 0, 1},
		{1, 4, 3, 0, 0, 1, 4, 1},
		{1, 1, 0, 3, 4, 1, 4, 1},
		{1, 0, 3, 3, 3, 3, 3, 1},
		{1, 0, 0, 0, 0, 2, 0, 1},
		{1, 1, 1, 1, 1, 1, 1, 1}
};

const int recMap_7[7][8] = {
		{1, 1, 1, 1, 1, 1, 1, 1},
		{1, 4, 4, 4, 4, 4, 0, 1},
		{1, 4, 0, 0, 0, 1, 4, 1},
		{1, 1, 0, 0, 4, 1, 4, 1},
		{1, 0, 0, 0, 0, 0, 0, 1},
		{1, 0, 0, 0, 0, 0, 0, 1},
		{1, 1, 1, 1, 1, 1, 1, 1}
};

const int map_8[8][8] = {
		{1, 1, 1, 1, 1, 1, 1, 1},
		{1, 0, 4, 0, 4, 0, 0, 1},
		{1, 0, 5, 4, 3, 5, 3, 1},
		{1, 0, 4, 1, 1, 2, 0, 1},
		{1, 0, 5, 3, 0, 5, 0, 1},
		{1, 0, 3, 0, 0, 3, 0, 1},
		{1, 0, 0, 0, 0, 0, 4, 1},
		{1, 1, 1, 1, 1, 1, 1, 1}
};

const int recMap_8[8][8] = {
		{1, 1, 1, 1, 1, 1, 1, 1},
		{1, 0, 4, 0, 4, 0, 0, 1},
		{1, 0, 4, 4, 0, 4, 0, 1},
		{1, 0, 4, 1, 1, 0, 0, 1},
		{1, 0, 4, 0, 0, 4, 0, 1},
		{1, 0, 0, 0, 0, 0, 0, 1},
		{1, 0, 0, 0, 0, 0, 4, 1},
		{1, 1, 1, 1, 1, 1, 1, 1}
};

const int map_9[9][7] = {
		{1, 1, 1, 1, 1, 0, 0},
		{1, 0, 0, 0, 1, 1, 0},
		{1, 0, 0, 3, 0, 1, 0},
		{1, 0, 3, 1, 0, 1, 1},
		{1, 0, 0, 1, 4, 4, 1},
		{1, 0, 3, 2, 4, 4, 1},
		{1, 1, 0, 0, 3, 0, 1},
		{0, 1, 1, 1, 0, 0, 1},
		{0, 0, 0, 1, 1, 1, 1}
};

const int recMap_9[9][7] = {
		{1, 1, 1, 1, 1, 0, 0},
		{1, 0, 0, 0, 1, 1, 0},
		{1, 0, 0, 0, 0, 1, 0},
		{1, 0, 0, 1, 0, 1, 1},
		{1, 0, 0, 1, 4, 4, 1},
		{1, 0, 0, 0, 4, 4, 1},
		{1, 1, 0, 0, 0, 0, 1},
		{0, 1, 1, 1, 0, 0, 1},
		{0, 0, 0, 1, 1, 1, 1}
};

const int map_10[9][10] = {
		{0, 0, 0, 1, 1, 1, 1, 1, 1, 0},
		{0, 1, 1, 1, 0, 0, 0, 0, 1, 1},
		{1, 1, 0, 0, 4, 4, 2, 0, 0, 1},
		{1, 0, 3, 1, 4, 4, 0, 1, 0, 1},
		{1, 0, 0, 3, 4, 4, 0, 3, 0, 1},
		{1, 0, 0, 3, 1, 1, 0, 1, 0, 1},
		{1, 1, 1, 0, 0, 3, 0, 3, 0, 1},
		{0, 0, 1, 1, 0, 0, 0, 0, 0, 1},
		{0, 0, 0, 1, 1, 1, 1, 1, 1, 1}
};

const int recMap_10[9][10] = {
		{0, 0, 0, 1, 1, 1, 1, 1, 1, 0},
		{0, 1, 1, 1, 0, 0, 0, 0, 1, 1},
		{1, 1, 0, 0, 4, 4, 0, 0, 0, 1},
		{1, 0, 0, 1, 4, 4, 0, 1, 0, 1},
		{1, 0, 0, 0, 4, 4, 0, 0, 0, 1},
		{1, 0, 0, 0, 1, 1, 0, 1, 0, 1},
		{1, 1, 1, 0, 0, 0, 0, 0, 0, 1},
		{0, 0, 1, 1, 0, 0, 0, 0, 0, 1},
		{0, 0, 0, 1, 1, 1, 1, 1, 1, 1}
};

const int map_11[8][7] = {
		{1, 1, 1, 1, 1, 1, 1},
		{1, 0, 0, 0, 0, 0, 1},
		{1, 0, 0, 5, 0, 0, 1},
		{1, 0, 5, 3, 5, 0, 1},
		{1, 5, 0, 2, 0, 5, 1},
		{1, 0, 5, 0, 5, 0, 1},
		{1, 0, 0, 4, 0, 0, 1},
		{1, 1, 1, 1, 1, 1, 1}
};

const int recMap_11[8][7] = {
		{1, 1, 1, 1, 1, 1, 1},
		{1, 0, 0, 0, 0, 0, 1},
		{1, 0, 0, 4, 0, 0, 1},
		{1, 0, 4, 0, 4, 0, 1},
		{1, 4, 0, 0, 0, 4, 1},
		{1, 0, 4, 0, 4, 0, 1},
		{1, 0, 0, 4, 0, 0, 1},
		{1, 1, 1, 1, 1, 1, 1}
};

const int map_12[9][9] = {
		{0, 1, 1, 1, 1, 1, 1, 1, 0},
		{0, 1, 0, 0, 2, 0, 0, 1, 0},
		{0, 1, 5, 3, 5, 3, 5, 1, 0},
		{0, 1, 0, 4, 3, 4, 0, 1, 0},
		{1, 1, 4, 0, 1, 0, 4, 1, 1},
		{1, 0, 0, 5, 3, 5, 0, 0, 1},
		{1, 0, 0, 0, 5, 0, 0, 0, 1},
		{1, 0, 0, 1, 1, 1, 0, 0, 1},
		{1, 1, 1, 1, 0, 1, 1, 1, 1}
};

const int recMap_12[9][9] = {
		{0, 1, 1, 1, 1, 1, 1, 1, 0},
		{0, 1, 0, 0, 0, 0, 0, 1, 0},
		{0, 1, 4, 0, 4, 0, 4, 1, 0},
		{0, 1, 0, 4, 0, 4, 0, 1, 0},
		{1, 1, 4, 0, 1, 0, 4, 1, 1},
		{1, 0, 0, 4, 0, 4, 0, 0, 1},
		{1, 0, 0, 0, 4, 0, 0, 0, 1},
		{1, 0, 0, 1, 1, 1, 0, 0, 1},
		{1, 1, 1, 1, 0, 1, 1, 1, 1}
};

const int map_13[8][10] = {
		{0, 1, 1, 1, 1, 0, 0, 0, 0},
		{1, 1, 0, 0, 1, 1, 1, 1, 0},
		{1, 0, 0, 3, 0, 0, 3, 1, 0},
		{1, 0, 3, 5, 4, 4, 5, 1, 1},
		{1, 0, 0, 5, 3, 3, 4, 0, 1},
		{1, 2, 0, 5, 4, 5, 4, 0, 1},
		{1, 1, 1, 1, 0, 0, 1, 1, 1},
		{0, 0, 0, 1, 1, 1, 1, 0, 0}
};

const int recMap_13[8][10] = {
		{0, 1, 1, 1, 1, 0, 0, 0, 0},
		{1, 1, 0, 0, 1, 1, 1, 1, 0},
		{1, 0, 0, 0, 0, 0, 0, 1, 0},
		{1, 0, 0, 4, 4, 4, 4, 1, 1},
		{1, 0, 0, 4, 0, 0, 4, 0, 1},
		{1, 0, 0, 4, 4, 4, 4, 0, 1},
		{1, 1, 1, 1, 0, 0, 1, 1, 1},
		{0, 0, 0, 1, 1, 1, 1, 0, 0}
};

const int map_14[10][9] = {
		{0, 0, 1, 1, 1, 1, 0, 0, 0},
		{0, 0, 1, 0, 0, 1, 1, 1, 1},
		{0, 1, 1, 2, 0, 3, 0, 0, 1},
		{0, 1, 0, 5, 4, 5, 0, 0, 1},
		{1, 1, 0, 5, 0, 5, 0, 1, 1},
		{1, 0, 0, 5, 0, 5, 0, 1, 0},
		{1, 0, 0, 5, 5, 5, 0, 1, 0},
		{1, 1, 0, 0, 0, 0, 0, 1, 0},
		{0, 1, 1, 1, 1, 0, 0, 1, 0},
		{0, 0, 0, 0, 1, 1, 1, 1, 0}
};

const int recMap_14[10][9] = {
		{0, 0, 1, 1, 1, 1, 0, 0, 0},
		{0, 0, 1, 0, 0, 1, 1, 1, 1},
		{0, 1, 1, 0, 0, 0, 0, 0, 1},
		{0, 1, 0, 4, 4, 4, 0, 0, 1},
		{1, 1, 0, 4, 0, 4, 0, 1, 1},
		{1, 0, 0, 4, 0, 4, 0, 1, 0},
		{1, 0, 0, 4, 4, 4, 0, 1, 0},
		{1, 1, 0, 0, 0, 0, 0, 1, 0},
		{0, 1, 1, 1, 1, 0, 0, 1, 0},
		{0, 0, 0, 0, 1, 1, 1, 1, 0}
};

const int map_15[8][9] = {
		{1, 1, 1, 1, 1, 1, 1, 0, 0},
		{1, 0, 0, 4, 4, 4, 1, 0, 0},
		{1, 0, 3, 4, 3, 5, 1, 1, 1},
		{1, 0, 0, 4, 5, 4, 3, 0, 1},
		{1, 1, 1, 4, 3, 2, 3, 0, 1},
		{0, 0, 1, 4, 3, 3, 3, 0, 1},
		{0, 0, 1, 0, 0, 0, 0, 0, 1},
		{0, 0, 1, 1, 1, 1, 1, 1, 1}
};

const int recMap_15[8][9] = {
		{1, 1, 1, 1, 1, 1, 1, 0, 0},
		{1, 0, 0, 4, 4, 4, 1, 0, 0},
		{1, 0, 0, 4, 0, 4, 1, 1, 1},
		{1, 0, 0, 4, 4, 4, 0, 0, 1},
		{1, 1, 1, 4, 0, 0, 0, 0, 1},
		{0, 0, 1, 4, 0, 0, 0, 0, 1},
		{0, 0, 1, 0, 0, 0, 0, 0, 1},
		{0, 0, 1, 1, 1, 1, 1, 1, 1}
};
/* Map End */
// 如果需要，可以自行增加关卡，注意尺寸不要太大，否则会超出界面的显示
// 但是你可以通过更改图片加载的大小（根据地图尺寸自动变化）来输出大尺寸地图